package xiangya.bysj.client.controller;

import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taobao.api.domain.ImMsg;

import xiangya.bysj.service.interf.IMServiceInterface;
import xiangya.bysj.util.JsonUtil;

/**
 * IM操作有关的controller
 * @author Mr.zhang
 *
 */
@Controller
@RequestMapping("/client/IM")
public class IMClientController {
	
	/**
	 * IMService 对象
	 */
	@Resource(name = "IMService")
	private IMServiceInterface IMService;
	
	private ImMsg imMsg;
	
	/**
	 * 发送消息
	 * @param json 客户端发来的json格式的消息
	 */
	@RequestMapping("/sendmsg")
	@ResponseBody
	public void sendMsg(String json){
		try{
			imMsg = (ImMsg) JsonUtil.getObject(json, ImMsg.class);
			IMService.sendMsg(imMsg);
		}catch(Exception e){
			e.printStackTrace();
		}finally {
			
		}
	}
	
	
}
